﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminIndexMaster.master" AutoEventWireup="true" CodeFile="Admin_Dictionary.aspx.cs" Inherits="Admin_Admin_Dictionary" %>

<asp:Content ID="cphContent" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="sm" runat="server">
    </asp:ScriptManager>
    <script src="Js/Jquery/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Js/Function.js" type="text/javascript"></script>
    <div class="TabText">
        <%--列表信息 begin--%>
        <asp:Panel ID="pnlManage" runat="server">
            <table class="nick" id="table_item" runat="server">
                <tr>
                    <td class="tit left1">
                        &nbsp;&nbsp;<asp:Literal ID="ltrTitle" runat="server">联系记录管理</asp:Literal>
                    </td>
                    <td class="tit" style="text-align: right;">
                        <a href="Admin_Dictionary.aspx?MenuID=6&MenuName=&#x7CFB;&#x7EDF;&FileName=添加字典表信息&action=addinfo">
                            <img style="border: 0px;" src="tpl/img/ico/add.gif" alt="添加" />新增 </a>&nbsp;&nbsp;
                    </td>
                </tr>
            </table>
            <table class="nick">
                <tr>
                    <td colspan="4" class="tit">
                        &nbsp;查询：
                    </td>
                </tr>
                <tr>
                    <td class="ltd">
                        标题：
                    </td>
                    <td class="rtd">
                        &nbsp;<asp:TextBox ID="txtSearchTitle" runat="server" Width="120px"></asp:TextBox>
                    </td>
                    <td class="rtd" colspan="2">
                        &nbsp;
                        <asp:Button ID="SeachBut" runat="server" Text="查询" OnClick="SeachBut_Click" />
                    </td>
                </tr>
            </table>
            <asp:GridView ID="gvManage" CssClass="adminlist" runat="server" AutoGenerateColumns="false"
                AllowPaging="True" OnRowDataBound="gvManage_RowDataBound" OnPageIndexChanging="gvManage_PageIndexChanging"
                PageSize="10">
                <Columns>
                    <asp:BoundField HeaderText="所属表名" DataField="TableName" />
                    <asp:BoundField HeaderText="字段名" DataField="FieldName" />
                    <asp:BoundField HeaderText="标题" DataField="Title" />
                    <asp:BoundField HeaderText="字段的文本值" DataField="FieldText"></asp:BoundField>
                    <asp:BoundField HeaderText="字段的实际值" DataField="FieldValue" />
                    <asp:TemplateField HeaderText="操作">
                        <ItemTemplate>
                            <asp:HyperLink ID="hyEditInfo" runat="server" Text="修改" NavigateUrl='<%# "Admin_Dictionary.aspx?MenuID=6&MenuName=&#x7CFB;&#x7EDF;&FileName=修改字典表信息&action=editinfo&fieldID="+Eval("FieldID") %>'></asp:HyperLink>
                            <asp:LinkButton ID="lbtnDelete" CommandName="DelInfo" CommandArgument='<%# Eval("FieldID") %>'
                                OnCommand="Button_Command" runat="server" OnClientClick="return confirm('确定要删除该信息吗？');">删除</asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    <table class="adminlist" width="100%">
                        <tr>
                            <th>
                                所属表名
                            </th>
                            <th>
                                字段名
                            </th>
                            <th>
                                标题
                            </th>
                            <th>
                                字段的文本值
                            </th>
                            <th>
                                字段的实际值
                            </th>
                        </tr>
                        <td colspan="5" style="text-align: center">
                            没有符合条件的联系人数据！
                        </td>
                    </table>
                </EmptyDataTemplate>
            </asp:GridView>
            <div class="page">
                <asp:Literal ID="ltrPagePanel" runat="server"></asp:Literal>
            </div>
        </asp:Panel>
        <%--列表信息 end--%>
        <%--添加/修改信息 begin--%>
        <asp:Panel ID="pnlAddOrEditInfo" runat="server">
            <table class="nick">
                <tr>
                    <td class="tit" colspan="2">
                        &nbsp;<asp:Label ID="lblAddOrEditTitle" runat="server" Text="添加字典表信息"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="ltd">
                        所属表名：
                    </td>
                    <td class="rtd">
                        <asp:DropDownList ID="ddlTableName" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlTableName_SelectedIndexChanged">
                            <asp:ListItem Value="" Text="请选择"></asp:ListItem>
                            <asp:ListItem Value="HL_Client" Text="HL_Client——客户表"></asp:ListItem>
                            <asp:ListItem Value="HL_ClientAnnal" Text="HL_ClientAnnal——客户联系记录表"></asp:ListItem>
                            <asp:ListItem Value="HL_ClientCompany" Text="HL_ClientCompany——客户公司表"></asp:ListItem>
                            <asp:ListItem Value="HL_ClientContacter" Text="HL_ClientContacter——客户联系人表"></asp:ListItem>
                            <asp:ListItem Value="HL_ClientServiceItem" Text="HL_ClientServiceItem——客户服务表"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="ltd">
                        字段名：
                    </td>
                    <td class="rtd">
                        <asp:UpdatePanel ID="upAddEdit" runat="server">
                            <ContentTemplate>
                                <asp:DropDownList ID="ddlFieldName" runat="server">
                                </asp:DropDownList>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="ddlTableName" EventName="SelectedIndexChanged" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td class="ltd">
                        标题：
                    </td>
                    <td class="rtd">
                        <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="ltd">
                        字段的文本值：
                    </td>
                    <td class="rtd">
                        <asp:TextBox ID="txtFieldText" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="ltd">
                        字段的实际值：
                    </td>
                    <td class="rtd">
                        <asp:TextBox ID="txtFieldValue" runat="server"></asp:TextBox>
                        <span style="color: Blue;">信息提交后，字段的实际值不能修改。</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center" style="text-align: center">
                        <asp:Button ID="btnSave" runat="server" Text="保存" OnClientClick="return checkPass()"
                            OnClick="btnSave_Click" />
                        <input type="button" id="btn" onclick="history.back()" value="返回" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <%--添加/修改信息 end--%>
    </div>
    <script type="text/javascript">
        //所属表
        function checkTable() {
            var objValue = "";
            var objSelect = document.getElementById("<%=ddlTableName.ClientID %>");
            for (var i = 0; i < objSelect.options.length; i++) {
                if (objSelect[i].selected == true) {
                    objValue = objSelect[i].value;
                }
            }
            if (objValue == "") {
                alert("请选择所属表！");
                return false;
            }
            return true;
        }
        //所属字段
        function checkField() {
            var objValue = "";
            var objSelect = document.getElementById("<%=ddlFieldName.ClientID %>");
            for (var i = 0; i < objSelect.options.length; i++) {
                if (objSelect[i].selected == true) {
                    objValue = objSelect[i].value;
                }
            }
            if (objValue == "") {
                alert("请选择所属表的字段！");
                return false;
            }
            return true;
        }
        //标题
        function checkTitle() {
            var txtTitle = $("#<%=txtTitle.ClientID %>"); //标题
            if (txtTitle.val().length == 0) {
                alert("标题不能为空!");
                txtTitle.focus();
                return false;
            }
            return true;
        }
        //字段的文本值
        function checkFieldText() {
            var txtFieldText = $("#<%=txtFieldText.ClientID %>"); //字段的文本值
            if (txtFieldText.val().length == 0) {
                alert("字段的文本值不能为空!");
                txtFieldText.focus();
                return false;
            }
            return true;
        }
        //字段的实际值
        function checkFieldValue() {
            var txtFieldValue = $("#<%=txtFieldValue.ClientID %>"); //字段的实际值
            if (txtFieldValue.val().length == 0) {
                alert("字段的实际值不能为空!");
                txtFieldValue.focus();
                return false;
            }
            return true;
        }
        function checkPass() {
            if (checkTable() && checkField() && checkTitle() && checkFieldText() && checkFieldValue()) {
                return true;
            } else {
                return false;
            }
        }
    </script>
</asp:Content>
